package com.hui.domain;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.*;

/**
 * @author Ayingzz
 * @create 2021/12/25 16:37
 */
@Data
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Song {
    String mid;// 曲目id
    String musicName;// 歌名
    String musicSinger;// 歌手
    String musicLyric; // 歌词
    String musicType;// 类型
    String musicImg;// 图片
    String musicUrlID;// 网易云外链ID
    String musicCreationTime; // 收录时间
    int musicPlayTimes;// 播放次数
    double musicScore;// 评分
    String musicComment;// 评论

    public Song(String json) throws JsonProcessingException {
        Song song = new ObjectMapper().readValue(json, Song.class);
        this.mid = song.getMid();
        this.musicName = song.getMusicName();
        this.musicSinger = song.getMusicSinger();
        this.musicLyric = song.getMusicLyric();
        this.musicType = song.getMusicType();
        this.musicImg = song.getMusicImg();
        this.musicUrlID = song.getMusicUrlID();
        this.musicCreationTime = song.getMusicCreationTime();
        this.musicPlayTimes = song.getMusicPlayTimes();
        this.musicScore = song.getMusicScore();
        this.musicComment = song.getMusicComment();
    }
}
